.class public Lcom/bitauto/autoeasy/news/Object/PromotionParser;
.super Ljava/lang/Object;
.source "PromotionParser.java"


# instance fields
.field private ID:Ljava/lang/String;

.field private PUBLISHTIME:Ljava/lang/String;

.field private TAG:Ljava/lang/String;

.field private TITLE:Ljava/lang/String;

.field private url:Ljava/lang/String;


# direct methods
.method public constructor <init>(Ljava/lang/String;)V
    .locals 1
    .parameter "url"

    .prologue
    .line 31
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 22
    const-string v0, "Title"

    iput-object v0, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->TITLE:Ljava/lang/String;

    .line 24
    const-string v0, "ID"

    iput-object v0, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->ID:Ljava/lang/String;

    .line 26
    const-string v0, "PublishTime"

    iput-object v0, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->PUBLISHTIME:Ljava/lang/String;

    .line 28
    const-string v0, ""

    iput-object v0, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->url:Ljava/lang/String;

    .line 29
    const-string v0, "PromotionParser"

    iput-object v0, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->TAG:Ljava/lang/String;

    .line 32
    iput-object p1, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->url:Ljava/lang/String;

    .line 33
    return-void
.end method


# virtual methods
.method public Paser2Object()Ljava/util/ArrayList;
    .locals 11
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/bitauto/autoeasy/news/Object/Promotion;",
            ">;"
        }
    .end annotation

    .prologue
    const/4 v9, 0x0

    const-string v10, "error :"

    .line 41
    :try_start_0
    iget-object v6, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->url:Ljava/lang/String;

    invoke-static {v6}, Lcom/bitauto/autoeasy/tool/Caller;->doGet(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    .line 42
    .local v5, str:Ljava/lang/String;
    if-eqz v5, :cond_1

    .line 43
    new-instance v4, Ljava/util/ArrayList;

    invoke-direct {v4}, Ljava/util/ArrayList;-><init>()V

    .line 44
    .local v4, proList:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/bitauto/autoeasy/news/Object/Promotion;>;"
    new-instance v2, Lorg/json/JSONArray;

    invoke-direct {v2, v5}, Lorg/json/JSONArray;-><init>(Ljava/lang/String;)V

    .line 47
    .local v2, jArry:Lorg/json/JSONArray;
    const/4 v1, 0x0

    .local v1, i:I
    :goto_0
    invoke-virtual {v2}, Lorg/json/JSONArray;->length()I

    move-result v6

    if-lt v1, v6, :cond_0

    move-object v6, v4

    .line 60
    .end local v1           #i:I
    .end local v2           #jArry:Lorg/json/JSONArray;
    .end local v4           #proList:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/bitauto/autoeasy/news/Object/Promotion;>;"
    .end local v5           #str:Ljava/lang/String;
    :goto_1
    return-object v6

    .line 48
    .restart local v1       #i:I
    .restart local v2       #jArry:Lorg/json/JSONArray;
    .restart local v4       #proList:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/bitauto/autoeasy/news/Object/Promotion;>;"
    .restart local v5       #str:Ljava/lang/String;
    :cond_0
    invoke-virtual {v2, v1}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v6

    invoke-virtual {p0, v6}, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->createPromotion(Lorg/json/JSONObject;)Lcom/bitauto/autoeasy/news/Object/Promotion;

    move-result-object v3

    .line 49
    .local v3, oil:Lcom/bitauto/autoeasy/news/Object/Promotion;
    invoke-virtual {v4, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Lcom/bitauto/autoeasy/tool/WSError; {:try_start_0 .. :try_end_0} :catch_1

    .line 47
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    .end local v1           #i:I
    .end local v2           #jArry:Lorg/json/JSONArray;
    .end local v3           #oil:Lcom/bitauto/autoeasy/news/Object/Promotion;
    .end local v4           #proList:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/bitauto/autoeasy/news/Object/Promotion;>;"
    :cond_1
    move-object v6, v9

    .line 54
    goto :goto_1

    .line 55
    .end local v5           #str:Ljava/lang/String;
    :catch_0
    move-exception v6

    move-object v0, v6

    .line 56
    .local v0, e:Lorg/json/JSONException;
    iget-object v6, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->TAG:Ljava/lang/String;

    new-instance v7, Ljava/lang/StringBuilder;

    const-string v8, "error :"

    invoke-direct {v7, v10}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Lorg/json/JSONException;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    invoke-static {v6, v7}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    move-object v6, v9

    .line 57
    goto :goto_1

    .line 58
    .end local v0           #e:Lorg/json/JSONException;
    :catch_1
    move-exception v6

    move-object v0, v6

    .line 59
    .local v0, e:Lcom/bitauto/autoeasy/tool/WSError;
    iget-object v6, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->TAG:Ljava/lang/String;

    new-instance v7, Ljava/lang/StringBuilder;

    const-string v8, "error :"

    invoke-direct {v7, v10}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Lcom/bitauto/autoeasy/tool/WSError;->getMessage()Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    invoke-static {v6, v7}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    move-object v6, v9

    .line 60
    goto :goto_1
.end method

.method public createPromotion(Lorg/json/JSONObject;)Lcom/bitauto/autoeasy/news/Object/Promotion;
    .locals 5
    .parameter "obj"

    .prologue
    .line 70
    new-instance v1, Lcom/bitauto/autoeasy/news/Object/Promotion;

    invoke-direct {v1}, Lcom/bitauto/autoeasy/news/Object/Promotion;-><init>()V

    .line 72
    .local v1, promotion:Lcom/bitauto/autoeasy/news/Object/Promotion;
    :try_start_0
    iget-object v2, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->ID:Ljava/lang/String;

    invoke-virtual {p1, v2}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Lcom/bitauto/autoeasy/news/Object/Promotion;->setID(Ljava/lang/String;)V

    .line 73
    iget-object v2, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->PUBLISHTIME:Ljava/lang/String;

    invoke-virtual {p1, v2}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Lcom/bitauto/autoeasy/tool/ToolBox;->String2Date(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Lcom/bitauto/autoeasy/news/Object/Promotion;->setPublishTime(Ljava/lang/String;)V

    .line 74
    iget-object v2, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->TITLE:Ljava/lang/String;

    invoke-virtual {p1, v2}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Lcom/bitauto/autoeasy/news/Object/Promotion;->setTitle(Ljava/lang/String;)V
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    move-object v2, v1

    .line 79
    :goto_0
    return-object v2

    .line 76
    :catch_0
    move-exception v2

    move-object v0, v2

    .line 77
    .local v0, e:Lorg/json/JSONException;
    const-string v2, "BrandParser"

    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, "error :"

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Lorg/json/JSONException;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 78
    invoke-virtual {v0}, Lorg/json/JSONException;->printStackTrace()V

    .line 79
    const/4 v2, 0x0

    goto :goto_0
.end method

.method public setUrl(Ljava/lang/String;)V
    .locals 0
    .parameter "url"

    .prologue
    .line 36
    iput-object p1, p0, Lcom/bitauto/autoeasy/news/Object/PromotionParser;->url:Ljava/lang/String;

    .line 37
    return-void
.end method
